package com.wd.elec.controller.bussiness;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONObject;
import com.wd.elec.domain.CnAreaBoundFull;
import com.wd.elec.service.ICnAreaBoundFullService;
import com.wd.elec.utils.FileUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wd.common.core.controller.BaseController;
import com.wd.common.core.domain.HttpResponse;
import com.wd.common.annotation.Log;
import com.wd.common.enums.BusinessType;
import com.wd.common.utils.poi.ExcelUtil;


/**
 * 【请填写功能名称】Controller
 * 
 * @author liumingkun
 * @date 2024-07-19
 */
@RestController
@RequestMapping("/bound/full")
public class CnAreaBoundFullController extends BaseController
{
    @Resource
    private ICnAreaBoundFullService cnAreaBoundFullService;

    @Value("${wd.jsonFile}")
    private String jsonFile;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('visitor:full:list')")
    @GetMapping("/list")
    public HttpResponse list(CnAreaBoundFull cnAreaBoundFull)
    {
        startPage();
        List<CnAreaBoundFull> list = cnAreaBoundFullService.selectCnAreaBoundFullList(cnAreaBoundFull);
        return HttpResponse.successData(getDataTable(list));
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('visitor:full:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CnAreaBoundFull cnAreaBoundFull)
    {
        List<CnAreaBoundFull> list = cnAreaBoundFullService.selectCnAreaBoundFullList(cnAreaBoundFull);
        ExcelUtil<CnAreaBoundFull> util = new ExcelUtil<CnAreaBoundFull>(CnAreaBoundFull.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('visitor:full:query')")
    @GetMapping(value = "/{id}")
    public HttpResponse getInfo(@PathVariable("id") Long id)
    {
        String jsonString = FileUtils.readFile(jsonFile, id + "_full.json");
        return successData(JSONObject.parseObject(jsonString));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('visitor:full:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public HttpResponse add(@RequestBody CnAreaBoundFull cnAreaBoundFull)
    {
        return getResult(cnAreaBoundFullService.insertCnAreaBoundFull(cnAreaBoundFull));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('visitor:full:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public HttpResponse edit(@RequestBody CnAreaBoundFull cnAreaBoundFull)
    {
        return getResult(cnAreaBoundFullService.updateCnAreaBoundFull(cnAreaBoundFull));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('visitor:full:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public HttpResponse remove(@PathVariable Long[] ids)
    {
        return getResult(cnAreaBoundFullService.deleteCnAreaBoundFullByIds(ids));
    }
}
